package com.wxn.servlet;
/*
 * Created by wxn
 * 2018/3/18 17:27
 */


import com.wxn.service.MaintainService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 删除一个
 */
public class DeleteOneServlet extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		/**
		 * 设置编码
		 */
		req.setCharacterEncoding("utf-8");
		/**
		 * 接受页面的值
		 */
		String id = req.getParameter("id");
		String command = req.getParameter("command");
		String description = req.getParameter("description");
		/**
		 * 删除数据
		 */
		MaintainService maintainService = new MaintainService();
		maintainService.deleteOne(id);
		/**
		 * 传回参数
		 */
		req.setAttribute("command",command);
		req.setAttribute("description",description);
		/**
		 * 向页面跳转
		 */
		req.getRequestDispatcher("/List.action").forward(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doGet(req,resp);
	}
}
